package lambda04;

import org.junit.Test;
/**
 * Lambda表达式原理
 */
public class LambdaDemo02 {
    @Test
    public void test01() {
        method02(13, 17, (a, b) -> a + b);
    }

    public void method02(int a, int b, Calculator c) {
        System.out.println(c.getSum(a, b));
    }

    @Test
    public void test02() throws Exception {

        Calculator c = (a, b) -> a + b;
        System.out.println(c);

        System.out.println(c.getClass());

        for (Class<?> in : c.getClass().getInterfaces()) {
            System.out.println(in);
        }

        System.out.println(c.getClass().getMethod("getSum", int.class, int.class));
    }
}

/*
public class LambdaDemo02 {
    @Test
    public void test02() {
        method02(13, 17, new LambdaDemo02$$Lambda());
    }

    public void method02(int a, int b, Calculator c) {//int a=13
        System.out.println(c.getSum(a, b));           //int b=17
                                                      //Calculator c=new LambdaDemo02$$Lambda()
                                                       //c.getSum(13,17)
    }

   class LambdaDemo02$$Lambda implements Calculator{
      public int getSum(int a,int b){
          return  a + b;
      }
   }

}

 */
